﻿using GameCreator.Core;
using Gp.Scripts.Core;
using Gp.Scripts.Data;
using UnityEngine;

namespace Gp.GCX {
    [AddComponentMenu("")]
    public class ActivatePuzzleAc : IAction {
        public BasePuzzle puzzle;
        public bool status;
        
 
        // public string characterName;

        public override bool InstantExecute(GameObject target, IAction[] actions, int index) {
            if (puzzle == null) return true;
            if (!status) {
                puzzle.DisablePuzzle();
                return true;
            }
            puzzle.EnablePuzzle();
            return true;
        }


#if UNITY_EDITOR
        public new static string NAME = "Gp/其他/修改解谜状态";
        private const string NODE_TITLE = "{0} 解谜 {1}";

        public override string GetNodeTitle()
        {
            string str = status ? "激活" : "禁用";
            string name = puzzle == null ? "无" : puzzle.name;
            return string.Format(NODE_TITLE, str, name);
        }

#endif
    }
}